const { sequelize } = require("../../core/db");
const { Sequelize, Model } = require("sequelize");

class Goods extends Model {}

Goods.init(
  {
    goods_id: {
      type: Sequelize.INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    admin_id: {
      type: Sequelize.INTEGER,
      comment: "商品管理员id",
    },
    price: {
      type: Sequelize.INTEGER,
      defaultValue: 0,
      comment: "价格",
    },
    goods_name: {
      type: Sequelize.STRING,
      comment: "商品名称",
    },
    goods_details: {
      type: Sequelize.TEXT,
      comment: "商品详情",
    },
    goods_stock: {
      type: Sequelize.STRING,
      comment: "商品库存",
    },
    goods_img: {
      type: Sequelize.STRING,
      comment: "商品图片",
    },
    sort: {
      type: Sequelize.INTEGER,
      defaultValue: 0,
      comment: "排序",
    },
    // 0:未上架,1:已上架
    is_on: {
      type: Sequelize.BOOLEAN,
      defaultValue: false,
      comment: "是否上架",
    },
  },
  {
    sequelize,
    tableName: "goods",
  }
);

module.exports = {
  Goods,
};
